using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace SsisUtilities.PacMan.Components
{
    public class FolderHelper
    {
        public static List<FileInfo> GetPackages(DirectoryInfo rootFolder)
        {
            List<FileInfo> packageList = new List<FileInfo>();

            GetPackagesInFolder(rootFolder, packageList);

            return packageList;
        }

        private static void GetPackagesInFolder(DirectoryInfo folder,
            List<FileInfo> packageList)
        {
            FileInfo[] packageFiles = folder.GetFiles("*.dtsx");
            foreach (FileInfo packageFile in packageFiles)
            {
                packageList.Add(packageFile);
            }

            foreach (DirectoryInfo subFolder in folder.GetDirectories())
            {
                GetPackagesInFolder(subFolder, packageList);
            }
        }
    }
}
